package com.zjy.pgcms.util;

import com.zjy.pgcms.common.ErrorCode;
import com.zjy.pgcms.exception.BusinessException;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author 音音音
 */
public class EncryptUtil {
    public static String encryptString(String str){
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(str.getBytes());
            byte[] digest = md5.digest();
            return new BigInteger(1,digest).toString();
        }catch (NoSuchAlgorithmException e){
            e.printStackTrace();
            throw new BusinessException(ErrorCode.SYSTEM_ERROR);
        }

    }
}
